package com.ly.honor.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.ly.honor.entity.Country;
import com.ly.honor.entity.PlayerPlace;
import com.ly.honor.entity.vo.PlayerPlaceQueryVO;
import com.ly.honor.service.PlayerPlaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author 李某人
 * @Date 2023/3/19 17:29
 * @Version 1.0
 */
@Component
public class PlayerPlaceConverter implements Converter<Integer> {


    private static PlayerPlaceService playerPlaceService;

    public PlayerPlaceConverter() {
    }

    @Autowired
    public PlayerPlaceConverter(PlayerPlaceService playerPlaceService) {
        PlayerPlaceConverter.playerPlaceService = playerPlaceService;
    }

    @Override
    public Class<?> supportJavaTypeKey() {
        return Converter.super.supportJavaTypeKey();
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return Converter.super.supportExcelTypeKey();
    }

    @Override
    public WriteCellData<String> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        PlayerPlaceQueryVO playerPlaceQueryVO = playerPlaceService.getPlayerPlaceById(value.longValue());
        return new WriteCellData<String>(playerPlaceQueryVO.getName());
    }
}
